cmake_minimum_required(VERSION 3.8.0 FATAL_ERROR)

project(libmod2-static-a)

include(${CMAKE_CURRENT_SOURCE_DIR}/../../../mkspecs/cmake/global.cmake)

file(GLOB_RECURSE API_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/api/*.h)
file(GLOB_RECURSE SRC_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/*.h)
file(GLOB_RECURSE SRC_CPPS    ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)
set(SOURCES ${API_HEADERS} ${SRC_HEADERS} ${SRC_CPPS})

include_directories(
    ${CMAKE_CURRENT_SOURCE_DIR}/api
    ${CMAKE_CURRENT_SOURCE_DIR}/src
    )

add_library(mod2-static-a STATIC ${SOURCES})
add_custom_command(TARGET mod2-static-a POST_BUILD
    COMMAND ${CMAKE_COMMAND} -E make_directory                           ${CYG_NOPUB_INC_PATH}/mod2-static-a
    COMMAND ${CMAKE_COMMAND} -E copy ${API_HEADERS}                      ${CYG_NOPUB_INC_PATH}/mod2-static-a
    COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_LINKER_FILE:mod2-static-a> ${CYG_NOPUB_LIB_PATH}/$<TARGET_LINKER_FILE_NAME:mod2-static-a>)
